package com.design.consumer.p02;

import java.util.concurrent.TimeUnit;

/**
 * 
 * 
 * 消费者线程
 * 
 *
 */
public class Consumer implements Runnable {

	/** 消费产品数量 */
	private int num;
	private Storage storage;

	public Consumer(Storage storage) {
		this.storage = storage;
	}

	@Override
	public void run() {
		while (true) {
			// 调用缓冲区的消费
			this.storage.consume(num);
			try {
				TimeUnit.SECONDS.sleep(2);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}

	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public Storage getStorage() {
		return storage;
	}

	public void setStorage(Storage storage) {
		this.storage = storage;
	}

}
